package org.jeecg.modules.vital.service.impl;

import org.jeecg.modules.vital.entity.MedicalRecordInformation;
import org.jeecg.modules.vital.entity.Allergichistory;
import org.jeecg.modules.vital.entity.Present;
import org.jeecg.modules.vital.entity.History;
import org.jeecg.modules.vital.entity.Diagnosis;
import org.jeecg.modules.vital.entity.TreatmentPlanning;
import org.jeecg.modules.vital.mapper.AllergichistoryMapper;
import org.jeecg.modules.vital.mapper.PresentMapper;
import org.jeecg.modules.vital.mapper.HistoryMapper;
import org.jeecg.modules.vital.mapper.DiagnosisMapper;
import org.jeecg.modules.vital.mapper.TreatmentPlanningMapper;
import org.jeecg.modules.vital.mapper.MedicalRecordInformationMapper;
import org.jeecg.modules.vital.service.IMedicalRecordInformationService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.List;
import java.util.Collection;

/**
 * @Description: 病历信息
 * @Author: jeecg-boot
 * @Date:   2023-01-04
 * @Version: V1.0
 */
@Service
public class MedicalRecordInformationServiceImpl extends ServiceImpl<MedicalRecordInformationMapper, MedicalRecordInformation> implements IMedicalRecordInformationService {

	@Autowired
	private MedicalRecordInformationMapper medicalRecordInformationMapper;
	@Autowired
	private AllergichistoryMapper allergichistoryMapper;
	@Autowired
	private PresentMapper presentMapper;
	@Autowired
	private HistoryMapper historyMapper;
	@Autowired
	private DiagnosisMapper diagnosisMapper;
	@Autowired
	private TreatmentPlanningMapper treatmentPlanningMapper;
	
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delMain(String id) {
		allergichistoryMapper.deleteByMainId(id);
		presentMapper.deleteByMainId(id);
		historyMapper.deleteByMainId(id);
		diagnosisMapper.deleteByMainId(id);
		treatmentPlanningMapper.deleteByMainId(id);
		medicalRecordInformationMapper.deleteById(id);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delBatchMain(Collection<? extends Serializable> idList) {
		for(Serializable id:idList) {
			allergichistoryMapper.deleteByMainId(id.toString());
			presentMapper.deleteByMainId(id.toString());
			historyMapper.deleteByMainId(id.toString());
			diagnosisMapper.deleteByMainId(id.toString());
			treatmentPlanningMapper.deleteByMainId(id.toString());
			medicalRecordInformationMapper.deleteById(id);
		}
	}
	
}
